home *** CD-ROM | disk | FTP | other *** search
- It is recommended that you print this out and then run the program
- and experiment as you read.
- ==========
-
- Audiotool was written to provide direct access to the Amiga's sound
- generating hardware. The Amiga has four Direct Memory Access (DMA)
- channels and four Digital to Analog (D/A) Converters (also called DACs).
- The DACs feed two audio line outputs (the left and right jacks on the back).
-
- In the normal operating mode, a DMA produces a stream of numbers
- (representing an audio waveform) to a DAC which converts it (with help from
- a filter stage and other hardware) to an analog signal which is then sent
- to a line output (represented by a speaker). The line output provides
- a continuos analog signal varying in strength within the limits of
- +/- 0.4 Volts. If the line is connected to an amplifier and speaker,
- the speaker vibrates, generating air vibrations we call sound.
-
- The timbre of the sound (the quality of a sound which differentiates
- it from others of the same frequency and amplitude) is controlled by the
- stream of numbers feeding the DMA. These are represented by four waveform
- representations in boxes (sine, square, ascending and descending sawtooth
- respectively). You may select one by clicking on a box with the left mouse
- button. The pitch or frequency of the sound is determined by two factors,
- the number of samples in the waveform representation, and the sampling
- frequency being used. Each number in the waveform representation is called
- a sample. The sequence of samples (in this program) represents one waveform
- cycle. One waveform cycle is one up and down movement of a wave (as
- represented by the waveform boxes). The top row of numbered boxes
- represent the number of samples in the waveform. A different number may be
- selected by clicking in a box with the left mouse button. The more samples,
- the lower the output frequency.
-
- The sampling frequency is the number of samples that are output from
- the DMA every second. This is controlled by the top slide pot.
- This pot may be thought of as a speed control for the DMA. The number
- selected by this pot is displayed in the box just above the slide pot
- on the left. This box is also a numeric input gadget. By clicking the
- left mouse button in this box and then using the delete, backspace, and
- numeric keys, you may enter a new number. But its easier to just hold
- the left mouse button down on the slide pot and move it back and forth.
- As the number selected increases, the output frequency decreases.
-
- The output frequency is displayed above the slide gadget to the right
- in Hertz. One Hertz is one cycle of sound per second.
-
- The DAC also has a slide pot, it controls the volume or amplitude of
- the sound (how loud it is). It operates similar to the other slide gadget.
- The bigger the number, the louder the sound.
-
- The outputs of the DACS are hardwired to the line outputs. In other
- words, there is no way to move a particular DAC's output to the other line
- (left or right) instead of the one it is connected to.
-
- The DMA inputs and output are much more versatile however. Each DMA
- has an on/off switch. It is the crude knife switch image just under the
- DMA box. Each knife switch may be toggled on/off or up/down by clicking
- the left mouse button over the image. (Yes, yes, always the left button,
- the right button is useless with this program, there aren't even any menus
- for Pete's sake.) The speed of a DMA controller may be switched from the
- manual pot to the output of the DMA on its left. This means that the
- frequency of the right DMA's output will vary by the waveform selected as
- input by the left DMA unit. Try this example, turn on the second DMA and
- select a nice audible tone. Now turn on the first DMA and select a
- frequency of about 2 Hz. To do this, select the 128 samples box and then
- move the frequency slide to the right. As you get below 30 Hz, the sound
- will become inaudible except for a clicking sound if you have selected a
- waveform with a sharp edge. Now click the second DMA's top toggle switch
- (the one that disconnects the DMA from the frequency slide gadget and
- connects it to the first DMA's output). Now select different waveforms.
- Fun, no?
-
- In the same way, the volume of a DAC may go from a steady level under
- manual control to modulation by the DMA channel on it's left. You can
- even modulate both frequency and volume at the same time.
-
-
-
- Features:
-
- There is no way to quickly switch the waveform input of a DMA
- channel. One must either turn off the DMA channel for more than two
- samples or let the hardware automatically reload its input address
- register after it finishes its current cycle. This program uses the
- latter. It becomes apparent when small frequencies are being used.
- Waveforms will not switch immediately when alternate waveforms are
- selected. When switches are thrown changing the routing of DMA output,
- some strange sounds are produced until the DMA resets itself with the
- new waveform. Sometimes, the DMA does not recover by itself. In these
- cases, the former method may be manually used by clicking off the DMA,
- and then clicking it back on.
-
- Equations:
-
- The frequency slide pot produces a number which is output to the
- Amiga's period register. It is a clock divider value. It divides the
- master clock rate of 3,579,545 ticks per second to produce the sampling
- frequency used by the DMA unit.
-
- Letting P = period register value
- N = number of samples per cycle in waveform representation
- F = output frequency
-
- cycles ticks ticks samples
- F ------ = 3,579,545 ------ divided by P ------- divided by N -------
- second second samples cycle
-
-
- The volume level is represented in decibels. This is the ratio of the
- output level to the maximum output level. The volume register can take on
- values from 1 to 64 (0 is off) yielding dB values according to the following
- formula:
-
- Letting V = volume register value
- D = decibel rating
-
- D = 20 * common log ( V / 64 )
-
-
-
- Technical notes:
-
- I have tried to produce a program that graphically interacts with
- the Amiga hardware that is simple yet not limiting.
-
- The DMA on/off switches each represent one bit in the DMA control
- register (DMACON). The remaining three switches per channel represent
- two bits in the audio control register (ADKCON). Hence not all switch
- combinations are legal. Opening up the switch that controls the feed
- into the top of a DAC for instance, must force the closure of at least
- one of the pot control switches for the channel on the DAC's right.
- The program arbitrarily closes the period control switch in this
- case because the author feels this is the most interesting case of the
- three. Here is a chart showing the bit values and the corresponding
- switch positions.
-
- feed feed "DAC feed" "period feed" "volume feed"
- period volume switch switch switch
-
- 0 0 closed open open
- 1 0 open closed open
- 0 1 open open closed
- 1 1 open closed closed
-
- To allow a full range of frequencies, I had to split the operation
- into six octaves. The middle four allow the frequency pot to select
- period values from 200 to 400. This is to allow reasonable operation of
- the slide gadget. However, any valid period value may be input with
- the numeric keys. Valid values are 124 to 65,535 inclusive. The outer
- two octave ranges lift the normal value restrictions to allow for more
- than a full octave. Here is a chart that shows what I mean.
-
- "samples" Pot selectable Frequency
- number period values range
-
- 4 124 to 400 7.2 kHz to 2.2 kHz
- 8 200 to 400 2.2 kHz to 1.1 kHz
- 16 200 to 400 1.1 kHz to 560 Hz
- 32 200 to 400 560 Hz to 280 Hz
- 64 200 to 400 280 Hz to 140 Hz
- 128 200 to 65535 140 Hz to 0.43 Hz
-
- The Amiga 1000 has a low pass filter that operates from 4 kHz to 7 kHz.
- It is possible to hear antialising distortion above 5 kHz with this program
- for this reason.
-
- Each octave range has its own set of samples for each of the four
- waveforms. This means that there are 6 * 4 or 24 sets of samples, not
- just four. But wait, its still more complicated yet. The DAC's take
- values ranging from -127 to 128, so that when a DMA is directly feeding
- a DAC, the waveform samples must have values ranging from -127 to 128.
- But when a DMA is switched to modulate the next channel's period register,
- it must produce valid period register values. These values range from 124
- to 65,535 as we have seen. This means another 24 sets of waveform sample
- values. When modulating periods, the samples take on values from 200 to
- 400, thus modulating frequencies by exactly one octave. When modulating
- the next channel's volume register, values from 10 to 64 are used, thus
- modulating volume by 16 decibels. When modulating both volume and period,
- twice as many samples are required. One for volume, then one for period,
- etc. Therefore there are:
-
- 4 (waveforms) * 6 (octave ranges) * 4 (operating modes) = 96 (sets of samples)
-
- The program automatically switches between these as required to make
- operation seem simple.
-
- The source code is available to answer other questions.
-
- This program expects to run in a 640 x 200 sized workbench window.
- A custom window may be opened instead by making a quick change to
- window.c.
-
- Comments, ideas, code improvements, and questions may be sent
- to the author. No reply guaranteed.
-
- David Reynolds
- 32 Greenwood Rd.
- Burlington, Ma 01803
-